﻿//                       NOTICE
// 
// This software was produced for the U. S. Government
// under Contract No. FA8721-10-C-0001, and is
// subject to the Rights in Noncommercial Computer Software
// and Noncommercial Computer Software Documentation Clause
// (DFARS) 252.227-7014 (JUN 1995)
// 
// � 2010 The MITRE Corporation. All Rights Reserved. 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Surface.Core;

namespace MXSE.MultiTouch.Gestures
{
    public class TapGesture : BasicGesture
    {
        bool updated;

        public TapGesture(TouchGesture touch)
        {
            Parent = touch.Parent;
            startPosition = touch.startPosition;
            startTime = touch.startTime;
            currentPosition = touch.currentPosition;
            endTime = DateTime.Now;
            Id = touch.Id;
        }

        public TapGesture(ContactEventArgs cea)
        {
            startPosition = new Microsoft.Xna.Framework.Vector2(cea.Contact.X, cea.Contact.Y);
            endTime = startTime = DateTime.Now;
            currentPosition = startPosition;
            Id = cea.Contact.Id;
        }

        public override void Update()
        {
            if (!updated)
            {
                base.Update();
                updated = true;
            }
        }

        public override bool Destroyed()
        {
            return (destroyed ||
                DateTime.Compare(DateTime.Now, endTime + DOUBLE_TAP_DELAY) > 0);
        }
    }
}
